package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.SurveyPeopleLogin;

/**
 * 
 * @author 
 *
 */
@DAO
public interface SurveyPeopleLoginDAO{
	
	@SQL("SELECT id,code,name,companyGroup,phone,surveyGroupIds,createAt,updateAt FROM SurveyPeopleLogin WHERE deleteFlag=1 #if(:t.name!=''){ AND name LIKE '%##(:t.name)%' } #if(:t.phone!=''){ AND phone LIKE '%##(:t.phone)%' } ORDER BY id DESC LIMIT :t.start,:t.length ")
    List<SurveyPeopleLogin> query(@SQLParam("t") SurveyPeopleLogin surveyPeopleLogin);
	
	@SQL("SELECT count(1) FROM SurveyPeopleLogin WHERE deleteFlag=1 #if(:t.name!=''){ AND name LIKE '%##(:t.name)%' } #if(:t.phone!=''){ AND phone LIKE '%##(:t.phone)%' } ")
    int querysize(@SQLParam("t") SurveyPeopleLogin surveyPeopleLogin);
	
	@SQL("SELECT id,code,name,companyGroup,phone,surveyGroupIds,createAt,updateAt FROM SurveyPeopleLogin WHERE deleteFlag=1 AND id=:1 ")
	SurveyPeopleLogin queryById(int id);
	
	@SQL("INSERT INTO SurveyPeopleLogin (code,name,companyGroup,phone,surveyGroupIds,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.code,:t.name,:t.companyGroup,:t.phone,:t.surveyGroupIds,1,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") SurveyPeopleLogin surveyPeopleLogin);
	
	@SQL("UPDATE SurveyPeopleLogin SET code=:t.code,name=:t.name,companyGroup=:t.companyGroup,phone=:t.phone,surveyGroupIds=:t.surveyGroupIds,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id")
    void update(@SQLParam("t") SurveyPeopleLogin surveyPeopleLogin);
	
	@SQL("UPDATE SurveyPeopleLogin SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}